/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.managerServer.executors;

import protocol.Executor;
import protocol.*;
import server.managerServer.ServerWorker;
import protocol.ThreadWorker;

/**
 *
 * @author radu
 */
public class ExecutorStart extends Executor {

    MessageStartReq msg;

    public ExecutorStart(Message _msg) {
        super(_msg);
        msg = (MessageStartReq) _msg;
    }

    @Override
    public void doWork(ThreadWorker worker) {
        ServerWorker serverWorker = (ServerWorker) worker;
        long pollId = msg.getPollId();

        if (!serverWorker.startPoll(pollId)) {
            serverWorker.sendMessage(new MessageError());
            return;
        }
        
        serverWorker.sendMessage(new MessageStartRep(pollId));
    }
}



/*
pause
resume
list
*/